package com.yh.common;

import lombok.Data;

/**
 * @author yh
 */
@Data
public class BaseResult {
    private Integer code;

    private String message;

    private Object data;

    public BaseResult(Integer code,String message){
        this.code = code;
        this.message = message;
    }

    public BaseResult(Integer code,String message,Object data){
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static BaseResult success(){
        return new BaseResult(200,"success");
    }

    public static BaseResult success(Object data){
            return new BaseResult(200,"success",data);
    }

    public static BaseResult error(WarningCode warningCode){
        return new BaseResult(warningCode.getCode(),warningCode.getMessage());
    }
}
